﻿#ifndef AIRIM_H
#define AIRIM_H

#include "GeneratedFiles/ui_AirIM.h"
#include "stdafx.h"

class AirIM : public QMainWindow
{
	Q_OBJECT

public:
	AirIM(QWidget *parent = nullptr, Qt::WindowFlags flags = 0);
    ~AirIM();
    void paintEvent(QPaintEvent* event);
#ifdef Q_OS_WIN32
    bool nativeEvent(const QByteArray& eventType, void* message, long* result);
	void changeEvent(QEvent* event);
#endif

public slots:
#ifdef Q_OS_WIN32
	void trayActived(QSystemTrayIcon::ActivationReason activeReason);
	void taryOpenMain();
	void trayClose();
    void on_minisizeSysButton_clicked();
    void on_maximizeSysButton_clicked();
    void on_closeSysButton_clicked();
#endif
    // searchEdit
    void on_searchEdit_textChanged(const QString);
	void returnPressed();
	void editingFinished();
	void contactsTreeWidget_clicked(const QModelIndex& index);
    void contactsTreeWidget_doubleClicked(const QModelIndex& index);
	void on_tabButtonRecentContacts_toggled(bool checked);
	void on_tabButtonContacts_toggled(bool checked);
	void on_tabButtonGroups_toggled(bool checked);
    // socket
    void socketConnected();
    void socketDisconnected();
    void socketError(QAbstractSocket::SocketError socketErr);
    void socketReadyRead();
    //void socketTimeout();
	
private:
	Ui::AirIMClass ui;
#ifdef Q_OS_WIN32
    QSystemTrayIcon* m_trayIcon;
    QMenu* m_trayIconMenu;
#endif
    QToolButton* m_searchButton;
	QMenu* m_statusMenu;
    QTcpSocket* m_socket;
    // User Data
    QString m_strAccount;
    QString m_strNickName;

public:
    // internal function
    void setSocket(QTcpSocket* s);
    //void setUserAccount(QString account);
    //void setUserNickName(QString nick);
    //void setStatusMessage(QString message);       // 签名
    //void setFavicon(QIcon ico);
};

#endif // AIRIM_H
